﻿
using CefSharp;
using CefSharp.OffScreen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace PidKeyReptile.Desktop.Helper
{
    public class JavaScripInvok
    {
        public static ChromiumWebBrowser webBrowser;

        public static void Initialize()
        {
            webBrowser = new ChromiumWebBrowser();
        }

        public static async Task<string> InovkAsync(string url)
        {
            webBrowser.Load(url);

            bool isLoad = true;

            webBrowser.FrameLoadEnd += async (s, t) =>
            {
                await Task.Delay(3000);
                isLoad = false;
            };

            while (isLoad)
            {
                await Task.Delay(1000);
            }
            return webBrowser.Address;
        }
    }
}
